import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
@Define.Table({ TableName: 'storeconfig' })
export class StoreConfig extends EntityObjectType<StoreConfig> {
    @Define.PrimaryKey()
    id: string;

    /**
     * 业务日时刻，小时
     *
     * @type {number}
     * @memberof StoreConfig
     */
    @Define.Column({
        DataType: Define.DataType.INT,
    })
    businessTime: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    ipv4Address: string;

    @Define.Column({
        DataType: Define.DataType.BOOL
    })
    allowSmallChange: boolean;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    smallChangeType: string;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    decimalPlace: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    industry: string;

    @Define.Column({
        DataType: Define.DataType.BOOL
    })
    allowCleanTable: boolean;

    @Define.Column({
        DataType: Define.DataType.BOOL
    })
    enableStock: boolean;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    storeId: string;


    /**
     * 商品预设备注
     *
     * @type {[]}
     * @memberof StoreConfig
     */
    @Define.Column({
        DataType: Define.DataType.JSON
    })
    presetRemarks: PresetRemarkItem[];

    /**
     * 用于支付宝的配置authoToken
     *
     * @type {string}
     * @memberof StoreConfig
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    alipayAuthToken: string;

    /**
     * 微信支付，商户号id
     *
     * @type {string}
     * @memberof StoreConfig
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    wechatMchId: string;

    /**
     * 用于配置微生活店铺id
     *
     * @type {string}
     * @memberof StoreConfig
     */
    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    welcrmShopId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    welcrmAppId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    welcrmAppKey: string;

    @Define.Column({
        DataType: Define.DataType.JSON
    })
    elemeAuthToken: {
        access_token: string;
        token_type: string;
        expires_in: number;
        refresh_token: string;
    };

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    elemeShopId: string;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    memberGetPointRote: number;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    memberPayPointRote: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}

export const SmallChangeType = {
    Discarded: 'discarded', //全部舍弃
    Rounded: 'rounded'  //四舍五入
}

interface PresetRemarkItem {
    type: 'orderItem' | 'order';
    content: string;
    indexNo: number;
}